﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
using System.ComponentModel;

namespace Core.Infrastructure.Controls
{
    [TemplatePart(Name = "Animation", Type = typeof(Storyboard))]
    public class BusyAnimation : Control
    {
        private Storyboard animation;

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            this.animation = (Storyboard)base.GetTemplateChild("Animation");
            UpdateAnimation();
        }

        public void UpdateAnimation()
        {
            if (this.animation != null)
            {
                this.animation.Begin();
            }
        }
    }
}

